home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / ham / sattrk31.tgz / sattrack-3.1.tar / SatTrack / src / sattrack / satprec.c < prev    next >
C/C++ Source or Header  |  1995-03-16  |  7KB  |  148 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*  Title       : satprec.c                                                   */
  4. /*  Author      : Manfred Bester                                              */
  5. /*  Date        : 28Oct93                                                     */
  6. /*  Last change : 15Mar95                                                     */
  7. /*                                                                            */
  8. /*  Synopsis    : Precession routines for the Earth's axis of rotation.       */
  9. /*                                                                            */
  10. /*                                                                            */
  11. /*  SatTrack is Copyright (c) 1992, 1993, 1994, 1995 by Manfred Bester.       */
  12. /*  All Rights Reserved.                                                      */
  13. /*                                                                            */
  14. /*  Permission to use, copy, and distribute SatTrack and its documentation    */
  15. /*  in its entirety for educational, research and non-profit purposes,        */
  16. /*  without fee, and without a written agreement is hereby granted, provided  */
  17. /*  that the above copyright notice and the following three paragraphs appear */
  18. /*  in all copies. SatTrack may be modified for personal purposes, but        */
  19. /*  modified versions may NOT be distributed without prior consent of the     */
  20. /*  author.                                                                   */
  21. /*                                                                            */
  22. /*  Permission to incorporate this software into commercial products may be   */
  23. /*  obtained from the author, Dr. Manfred Bester, 1636 M. L. King Jr. Way,    */
  24. /*  Berkeley, CA 94709, USA. Note that distributing SatTrack 'bundled' in     */
  25. /*  with ANY product is considered to be a 'commercial purpose'.              */
  26. /*                                                                            */
  27. /*  IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, */
  28. /*  SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF   */
  29. /*  THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS BEEN ADVISED  */
  30. /*  OF THE POSSIBILITY OF SUCH DAMAGE.                                        */
  31. /*                                                                            */
  32. /*  THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT      */
  33. /*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A   */
  34. /*  PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"      */
  35. /*  BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, */
  36. /*  UPDATES, ENHANCEMENTS, OR MODIFICATIONS.                                  */
  37. /*                                                                            */
  38. /******************************************************************************/
  39.  
  40. #include <stdio.h>
  41. #include <math.h>
  42.  
  43. #ifndef STDLIB
  44. #include <stdlib.h>
  45. #endif
  46.  
  47. #include "satglobalsx.h"
  48. #include "sattrack.h"
  49.  
  50. /******************************************************************************/
  51. /*                                                                            */
  52. /* getPrecMatrix: calculates the precession matrix for the mean equinox       */
  53. /*                1950.0 using the rigorous formulae given in the             */
  54. /*                "The Astronomical Almanac", 1983, page B18                  */
  55. /*                and the matrix elements given in                            */
  56. /*                "Explanatory Supplement to the Ephemeris", 1974, page 31    */
  57. /*                                                                            */
  58. /*                time used for calculation : Julian date referred to UTC     */
  59. /*                                                                            */
  60. /******************************************************************************/
  61.  
  62. void getPrecMatrix()
  63.  
  64. {
  65.     double tu, tusq, tucb, zeta, zett, thet;
  66.     double coszeta, coszett, costhet, sinzeta, sinzett, sinthet, c, d;
  67.     int    i, j;
  68.  
  69.     if (fabs(julianDate - lastJulianDatePrec) < PRECUPDATEINT)
  70.         return;
  71.  
  72.     lastJulianDatePrec = julianDate;
  73.  
  74.     tu   = (julianDate - JULDAT1950) / TROPCENT;
  75.     tusq = tu*tu;
  76.     tucb = tu*tusq;
  77.  
  78.     zeta = (0.6402633*tu + 0.0000839*tusq + 0.0000050*tucb)*CDR;
  79.     zett = (0.6402633*tu + 0.0003036*tusq + 0.0000050*tucb)*CDR;
  80.     thet = (0.5567376*tu - 0.0001183*tusq - 0.0000117*tucb)*CDR;
  81.  
  82.     coszeta = cos(zeta);
  83.     coszett = cos(zett);
  84.     costhet = cos(thet);
  85.     sinzeta = sin(zeta);
  86.     sinzett = sin(zett);
  87.     sinthet = sin(thet);
  88.  
  89.     c = coszeta*costhet;
  90.     d = sinzeta*costhet;
  91.  
  92.     /*  regular precession matrix */
  93.  
  94.     precMatrix[0][0] =  c*coszett - sinzeta*sinzett;
  95.     precMatrix[0][1] = -d*coszett - coszeta*sinzett;
  96.     precMatrix[0][2] = -sinthet*coszett;
  97.     precMatrix[1][0] =  c*sinzett + sinzeta*coszett;
  98.     precMatrix[1][1] = -d*sinzett + coszeta*coszett;
  99.     precMatrix[1][2] = -sinthet*sinzett;
  100.     precMatrix[2][0] =  coszeta*sinthet;
  101.     precMatrix[2][1] = -sinzeta*sinthet;
  102.     precMatrix[2][2] =  costhet;
  103.  
  104.     /* use unity matrix for now; this seems to be the right one */
  105.  
  106.     precMatrix[0][0] =  1.0;
  107.     precMatrix[0][1] =  0.0;
  108.     precMatrix[0][2] =  0.0;
  109.     precMatrix[1][0] =  0.0;
  110.     precMatrix[1][1] =  1.0;
  111.     precMatrix[1][2] =  0.0;
  112.     precMatrix[2][0] =  0.0;
  113.     precMatrix[2][1] =  0.0;
  114.     precMatrix[2][2] =  1.0;
  115.  
  116.     /* transposed precession matrix, probably not needed */
  117.  
  118.     for (i = 0; i <= 2; i++)
  119.     {
  120.         for (j = 0; j <= 2; j++)
  121.         {
  122.             precMatrixTr[i][j] = precMatrix[j][i];
  123.         }
  124.     }
  125.  
  126. /*
  127.     printf("\nprecession matrices :\n");
  128.  
  129.     for (i = 0; i <= 2; i++)
  130.         printf("%+2.10f      %+2.10f      %+2.10f\n",
  131.                 precMatrix[i][0],precMatrix[i][1],precMatrix[i][2]);
  132.     printf("\n");
  133.  
  134.     for (i = 0; i <= 2; i++)
  135.         printf("%+2.10f      %+2.10f      %+2.10f\n",
  136.                 precMatrixTr[i][0],precMatrixTr[i][1],precMatrixTr[i][2]);
  137.     printf("\n");
  138. */
  139.  
  140.     return;
  141. }
  142.  
  143. /******************************************************************************/
  144. /*                                                                            */
  145. /* End of function block satprec.c                                            */
  146. /*                                                                            */
  147. /******************************************************************************/
  148.